package com.leanote.berial.tingphone.bean;

/**
 * Created with InetlliJ IDEA.
 * Project: com.liuhui.zhufengfm.app.bean
 * user  Pinocchio
 * Date 2015/7/28
 * Email:liu594545591@126.com
 */

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.LinkedList;
import java.util.List;

/**
 * 分类与Tag集合,一个分类包含了Tag
 */
public class CategoryTagMenu {
    private String name;
    private String title;
    private String intro;
    private String coverPath;

    private int id;

    private boolean display;//对应is_display

    private List<String> tag_list;

    public CategoryTagMenu() {
    }

    /**
     * 所有实体类都会包含这个方法
     *
     * @param jsonObject
     */
    public void parseJSON(JSONObject jsonObject) throws JSONException {
        if (jsonObject != null) {
            id = jsonObject.getInt("id");
            name = jsonObject.getString("name");
            title = jsonObject.getString("title");
            //可选内容
            intro = jsonObject.optString("intro");
            coverPath = jsonObject.getString("cover_path");
//            display = jsonObject.getBoolean("is_display");

            JSONArray array = jsonObject.optJSONArray("tag_list");
            if (array != null) {
                tag_list = new LinkedList();
                for (int i = 0; i < array.length(); i++) {
                tag_list.add(array.getString(i));
                }
            }
        }

    }

    public CategoryTagMenu(String name, String title, String intro, String coverPath, int id, boolean display, List<String> tag_list) {
        this.name = name;
        this.title = title;
        this.intro = intro;
        this.coverPath = coverPath;
        this.id = id;
        this.display = display;
        this.tag_list = tag_list;
    }

    public String getName() {
        return name;
    }

    public String getTitle() {
        return title;
    }

    public String getIntro() {
        return intro;
    }

    public String getCoverPath() {
        return coverPath;
    }

    public int getId() {
        return id;
    }

    public boolean isDisplay() {
        return display;
    }

    public List<String> getTag_list() {
        return tag_list;
    }

    @Override
    public String toString() {
        return "CategoryTagMenu{" +
                "name='" + name + '\'' +
                ", title='" + title + '\'' +
                ", intro='" + intro + '\'' +
                ", coverPath='" + coverPath + '\'' +
                ", id=" + id +
                ", display=" + display +
                ", tag_list=" + tag_list +
                '}';
    }


}
